setwd("/Users/eimei/Documents/Rdata/")  # 设定工作空间
data <- read.csv("temp18.csv")  # 读取数据

# X为对象的时候
aggdata <- aggregate(data, by = list(data$性别), FUN = mean, na.action = na.omit)
aggdata

aggdata <- aggregate(data, by = list(data$部门, data$性别), FUN = mean)
aggdata

# X为公式（formula）的时候
aggdata <- aggregate(月薪 ~ 部门, data, FUN = mean)
aggdata

aggdata <- aggregate(月薪 ~ 部门 + 性别, data, FUN = mean)
aggdata